using System;
using System.Data;

namespace MetaView.Core;

internal class DataTableFastBinaryConverter : FastBinaryConverter<DataTable>
{
    protected override DataTable Read<TByteBlock>(ref TByteBlock byteBlock, Type type)
    {
        var bytes = byteBlock.ReadBytesPackage();
        return SerializeConvert.BinaryDeserialize<DataTable>(bytes);
    }

    protected override void Write<TByteBlock>(ref TByteBlock byteBlock, in DataTable obj)
    {
        var bytes = SerializeConvert.BinarySerialize(obj);
        byteBlock.WriteBytesPackage(bytes);
    }
}